$(document).ready(function() {
	ko.applyBindings(new marketsViewModel(), $("#markets-container")[0]);
	$("#goToMarketsLink").addClass("active");
});

function marketsViewModel() {
	var self = this;
	
	self.markets = ko.observableArray();
	
	self.getMarketsSuccess = function(markets) {
		self.markets($.map(markets.elements, function (market) { return new Market(market); }));
	};
	
	self.showMarkets = function(markets) {
		$(markets).show();
	};
	
	self.pager = ko.observable(new Pager({ webService: "markets/getAllMarkets", params : { "pageNumber" : parseInt(getHashValue("page") || 1), "pageSize" : 12, 'topPx': 0, 'changeUrl': true }, onSuccess: self.getMarketsSuccess }));
};